<template>
  <div v-enter-helper="getList" class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <el-row>
          <el-form
            ref="dataList2"
            :inline="true"
            :model="listQuery"
            class="demo-form-inline"
          >


            <el-form-item label="">
              <el-date-picker
                v-model="listQuery.start_at"
                class="marginRB10"
                clearable
                placeholder="开始时间"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="">
              <el-date-picker
                v-model="listQuery.end_at"
                class="marginRB10"
                clearable
                placeholder="结束时间"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="">
              <el-input
                v-model.number="listQuery.room_code"
                clearable
                placeholder="请输入房间ID"
                type="text"
              ></el-input>
            </el-form-item>
            <el-form-item label="">
              <el-input
                v-model.number="listQuery.user_code"
                clearable
                placeholder="用户ID"
                type="text"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="searchSubmit">查询</el-button>
              <el-button type="primary" @click="resetSubmit">重置</el-button>
            </el-form-item>
          </el-form>
        </el-row>
      </div>
      <div class="item">
        <el-table
          ref="dataList"
          v-loading="listLoading"
          :data="menuList"
          :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
          border
          row-key="id"
          style="width:100%;margin-bottom: 20px;"
        >
          <!-- <el-table-column type="selection"></el-table-column> -->
          <el-table-column label="ID" prop="id"></el-table-column>
          <el-table-column label="房间ID" prop="room.code"></el-table-column>
          <el-table-column label="用户ID" prop="user.code"></el-table-column>
          <el-table-column label="用户名称" prop="user.nickname"></el-table-column>
          <el-table-column label="总金额" prop="coin"></el-table-column>
          <el-table-column label="返利金币" prop="init_coin"></el-table-column>
          <el-table-column
            label="时间"
            prop="created_at"
          ></el-table-column>

          <el-table-column label="操作" width="100px">
            <template slot-scope="scope">
              <el-button
                plain
                size="mini"
                type="primary"
                @click="handleDetail(scope.row)"
              >查看详情
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <cus-pagination
          :limit.sync="listQuery.per_page"
          :page.sync="listQuery.page"
          :total="total"
          @pagination="getList"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import { listData } from '@/api/room/rocketRecord'

export default {
  data() {
    return {
      confirmBtn: false,
      deleteDialogVisible: false,
      listLoading: false,
      menuList: [],
      total: 10,
      date: null,
      listQuery: {
        page: 1,
        per_page: 10,
        user_code: undefined,
        room_code: undefined,
        start_at: undefined,
        end_at: undefined
      },
      dataIds: ''
    }
  },
  async created() {
    await this.getList()
  },
  methods: {
    async getList() {
      const res = await listData(this.listQuery)
      this.menuList = res.data.list
      this.total = res.data.meta.total
      this.confirmBtn = false
    },
    // 查询
    searchSubmit() {
      this.listQuery.page = 1
      this.getList()
    },
    // 重置
    resetSubmit() {
      this.listQuery = {
        page: 1,
        per_page: 10,
        user_code: undefined,
        room_code: undefined,
        start_at: undefined,
        end_at: undefined
      }
      this.getList()
    },
    // 点击单个删除
    handleDetail(row) {
      // this.dataIds = { ids: row.id.toString() }
      // this.deleteDialogVisible = true
      this.$router.push({
        path: '/room/rocketRecordDetail',
        query: { id: row.id }
      })
    }
  }
}
</script>

<style scoped>
[v-cloak] {
  display: none;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}

.box-card {
  width: 100%;
}

.demo-form-inline {
  /* float: right; */
}

/deep/ .el-card__header {
  padding-bottom: 0;
}
</style>
